<?php
namespace org\crawlgenie\models;
use \Logger;
use \CGException;
/**
 * Description of BaseModel
 *
 * @author Jinson
 */


abstract class BaseModel {

   public function toArray() {
        return $this->processArray(get_object_vars($this));
    }

    protected function processArray($array) {
        foreach($array as $key => $value) {
            if (is_object($value)) {
                $array[$key] = $value->toArray();
            }
            if (is_array($value)) {
                $array[$key] = $this->processArray($value);
            }
        }
        // If the property isn't an object or array, leave it untouched
        return $array;
    }

    public function __toString() {
        return json_encode($this->toArray());
    }

}?>